package com.kehutong.contact.entity;

import com.kehutong.contact.enums.RoleType;
import org.coraframework.bean.valid.CheckField;
import org.coraframework.orm.Entity;
import org.coraframework.orm.annotation.Column;
import org.coraframework.orm.annotation.Table;
import org.coraframework.orm.util.IDType;

import java.time.LocalDate;
import java.time.LocalDateTime;
import java.util.List;
import java.util.Objects;

/**
 * 联系人
 * @author liujinwang
 */
@Table(value="t_contact",comment="联系人表", multi=true, idType= IDType.TIMESTAMP)
public class Contact extends Entity {
    private static final long serialVersionUID = -1859828959480040715L;

    protected Contact(String id) {
        super(id);
    }

    @CheckField("联系人姓名不能为空")
    @Column(comment = "联系人姓名")
    private String contactName;

    @Column(comment = "关联客户id")
    private String customerId;

    @CheckField("关联客户不能为空")
    @Column(comment = "关联客户")
    private String corpFullName;

    @Column(comment = "尊称 1先生，2女士",defValue = "NOT NULL default '0'")
    private String sirOrLady;

    @Column(comment = "角色")
    private RoleType role;

    @Column(comment = "生日")
    private LocalDate birthday;

    @Column(comment = "职位")
    private String position;

    @CheckField("联系人姓名不能为空")
    @Column(comment = "手机号码")
    private String mobile;

    @Column(comment = "固定电话")
    private String telephone;

    @Column(comment = "传真号码")
    private String fax;

    @Column(comment = "电子邮箱")
    private String email;

    @Column(comment = "微信账号")
    private String wechat;

    @Column(comment = "QQ号码")
    private String qq;

    @Column(comment = "所在地区")
    private String areaName;

    @Column(comment = "详细地址")
    private String detailAddress;

    @Column(comment = "备注信息",length = 300)
    private String remarkMsg;

    @CheckField("联系人姓名不能为空")
    @Column(comment = "跟进人员")
    private String followUpName;

    @Column(comment = "跟进人员id")
    private String followUpId;

    @Column(comment="首要联系人")
    private boolean firstContact;

    @Column(comment = "最后跟进时间")
    private LocalDateTime lastFollowUpTime;

    @Column(comment="逻辑删除")
    private boolean deleted;

    public String getCustomerId() {
        return customerId;
    }

    public void setCustomerId(String customerId) {
        this.customerId = customerId;
    }

    public String getContactName() {
        return contactName;
    }

    public void setContactName(String contactName) {
        this.contactName = contactName;
    }

    public String getCorpFullName() {
        return corpFullName;
    }

    public void setCorpFullName(String corpFullName) {
        this.corpFullName = corpFullName;
    }

    public String getSirOrLady() {
        return sirOrLady;
    }

    public void setSirOrLady(String sirOrLady) {
        this.sirOrLady = sirOrLady;
    }

    public RoleType getRole() {
        return role;
    }

    public void setRole(RoleType role) {
        this.role = role;
    }

    public LocalDate getBirthday() {
        return birthday;
    }

    public void setBirthday(LocalDate birthday) {
        this.birthday = birthday;
    }

    public String getPosition() {
        return position;
    }

    public void setPosition(String position) {
        this.position = position;
    }

    public String getMobile() {
        return mobile;
    }

    public void setMobile(String mobile) {
        this.mobile = mobile;
    }

    public String getTelephone() {
        return telephone;
    }

    public void setTelephone(String telephone) {
        this.telephone = telephone;
    }

    public String getFax() {
        return fax;
    }

    public void setFax(String fax) {
        this.fax = fax;
    }

    public String getEmail() {
        return email;
    }

    public void setEmail(String email) {
        this.email = email;
    }

    public String getWechat() {
        return wechat;
    }

    public void setWechat(String wechat) {
        this.wechat = wechat;
    }

    public String getQq() {
        return qq;
    }

    public void setQq(String qq) {
        this.qq = qq;
    }

    public String getAreaName() {
        return areaName;
    }

    public void setAreaName(String areaName) {
        this.areaName = areaName;
    }

    public String getDetailAddress() {
        return detailAddress;
    }

    public void setDetailAddress(String detailAddress) {
        this.detailAddress = detailAddress;
    }

    public String getRemarkMsg() {
        return remarkMsg;
    }

    public void setRemarkMsg(String remarkMsg) {
        this.remarkMsg = remarkMsg;
    }

    public String getFollowUpName() {
        return followUpName;
    }

    public void setFollowUpName(String followUpName) {
        this.followUpName = followUpName;
    }

    public String getFollowUpId() {
        return followUpId;
    }

    public void setFollowUpId(String followUpId) {
        this.followUpId = followUpId;
    }

    public boolean isFirstContact() {
        return firstContact;
    }

    public void setFirstContact(boolean firstContact) {
        this.firstContact = firstContact;
    }

    public LocalDateTime getLastFollowUpTime() {
        if (Objects.isNull(lastFollowUpTime)) {
            lastFollowUpTime = LocalDateTime.now();
        }
        return lastFollowUpTime;
    }

    public void setLastFollowUpTime(LocalDateTime lastFollowUpTime) {
        this.lastFollowUpTime = lastFollowUpTime;
    }

    public boolean isDeleted() {
        return deleted;
    }

    public void setDeleted(boolean deleted) {
        this.deleted = deleted;
    }
}
